﻿using System;
using System.Windows;
using ControleRepresentanteSync.Application.Wizard;

namespace ControleRepresentanteSync.View.Wizard
{
    public abstract class WizardPageViewModelBase : ViewModelBase, IWizardPageViewModel
    {
        public static readonly DependencyProperty IsValidProperty =
            DependencyProperty.Register("IsValid", typeof(bool), typeof(WizardPageViewModelBase));
        public static readonly DependencyProperty TitleProperty =
            DependencyProperty.Register("Title", typeof (string), typeof (WizardPageViewModelBase));
        public static readonly DependencyProperty DescriptionProperty = 
            DependencyProperty.Register("Description", typeof (string), typeof (WizardPageViewModelBase));

        protected WizardPageViewModelBase(string title, string description)
        {
            Title = title;
            Description = description;
        }

        public string Title
        {
            get { return (string) GetValue(TitleProperty); }
            set { SetValue(TitleProperty, value); }
        }

        public string Description
        {
            get { return (string)GetValue(DescriptionProperty); }
            set { SetValue(DescriptionProperty, value); }
        }

        public bool TryApply()
        {
            WizardPageTryApplyEventArgs wizardPageTryApplyEventArgs = new WizardPageTryApplyEventArgs();
            if (TryApplyRequested != null)
                TryApplyRequested(this, wizardPageTryApplyEventArgs);
            return wizardPageTryApplyEventArgs.Result;
        }

        public event EventHandler<WizardPageTryApplyEventArgs> TryApplyRequested;

        public bool IsValid
        {
            get { return (bool)GetValue(IsValidProperty); }
            set { SetValue(IsValidProperty, value); }
        }
    }
}